import java.io.*;
import java.util*;

public class Search extends Events{

public void seachUsingString(String oldVal, String newVal) {// searching the old or new event using the event name
   
    if ( oldVal != null && (newVal.length() < oldVal.length()) ) {// save the old and new event value
       
        list.setItems( entries );
    }
     
    String[] parts = newVal.toUpperCase().split(" ");
 
    ObservableList<String> subEventEntries = EventList.observableArrayList();// checks the event that's not on the list
    for ( Object entry: list.getItems() ) {
        boolean match = true;
        String entryText = (String)entry;
        for ( String part: parts ) {
            if ( ! entryText.toUpperCase().contains(part) ) {
                match = false;
                break;
            }
        }
 
        if ( match ) {
            subEventEntries.add(entryText);
        }
    }
    list.setItems(subEventEntries);
}
}